﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Yugi.Client.ViewModel;
namespace Yugi_Gui.COntrol
{
    /// <summary>
    /// Interaction logic for ChannelControl.xaml
    /// </summary>
    public partial class ChannelControl : UserControl
    {
        ChannelModel model;
        MainServerHandler main;
        ChatControl chat_control;
        public ChannelControl(MainServerHandler m)
        {
            InitializeComponent();

            main = m;
            model = m.ChatManager_Model.Channel_Model;

            tabControl1.SelectionChanged+=new SelectionChangedEventHandler(tabControl1_SelectionChanged);
            chat_control = new ChatControl(main, true);
            chat_control.InitModel(model.ListChannel[0]);
            chat_control.button2.IsHitTestVisible = false;

            tabControl1.Height = 40;
            tabControl1.MouseEnter += new MouseEventHandler(tabControl1_MouseEnter);
            tabControl1.MouseLeave += new MouseEventHandler(tabControl1_MouseLeave);
            this.chat_control.Resources.Source=
                 new Uri("pack://application:,,,/control/ShinyBlue.xaml", UriKind.Absolute);
            
        }

        void tabControl1_MouseLeave(object sender, MouseEventArgs e)
        {
            tabControl1.Height = 40;
        }

        void tabControl1_MouseEnter(object sender, MouseEventArgs e)
        {
            
            tabControl1.Height = 320;
        }

      





        void tabControl1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            TabItem item1 = (TabItem)chat_control.Parent;
            if (item1 != null)
                item1.Content = null;
            TabItem item = (TabItem)tabControl1.SelectedItem;
            item.Content = chat_control;
            switch ((string)item.Header)
            {
                case "World":
                    chat_control.InitModel(model.ListChannel[0]);
                    break;
                case "Duel":
                    chat_control.InitModel(model.ListChannel[1]);
                    break;
                case "Trade":
                    chat_control.InitModel(model.ListChannel[2]);
                    break;
                case "Room":
                    chat_control.InitModel(model.ListChannel[3]);
                    break;
                case "Friends":
                    chat_control.InitModel(model.ListChannel[4]);
                    break;
                case "Guild":
                    chat_control.InitModel(model.ListChannel[5]);
                    break;
            }
        }


        public void AddCanvas(Canvas can, int x,int y)
        {
            Canvas.SetLeft(this, x);
            Canvas.SetTop(this, y);
            can.Children.Add(this);
            
        }
        
    }
}
